/**
 * Copyright (C), 2022-2025, www.bosssof.com.cn
 * @FileName UserApi.java
 * @Author Administrator
 * @Date 2022-9-28  20:56
 * @Description 文件定义了用户管理界面的接口，主要包括用户增改查以及用户角色分配等
 * History:
 * <author> Administrator
 * <time> 2022-9-28  20:56
 * <version> 1.0.0
 * <desc> 文件定义了用户管理界面的接口，主要包括用户增改查以及用户角色分配等
 */
package com.sd365.permission.centre.api;
import com.sd365.permission.centre.entity.Department;
import com.sd365.permission.centre.entity.Position;
import com.sd365.permission.centre.entity.Role;
import com.sd365.permission.centre.entity.User;
import com.sd365.permission.centre.pojo.dto.UserDTO;
import com.sd365.permission.centre.pojo.query.UserQuery;
import com.sd365.permission.centre.pojo.vo.ResourceVO;
import com.sd365.permission.centre.pojo.vo.UserVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.Data;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;
/**
 * @author yangshaoqi
 * @version 1.0.0
 * @class UserApi
 * @classdesc 用户管理接口 主要是包含增删改查以及对用户分配角色
 * @date 2020.12.14  20点28分
 */
@CrossOrigin
@Api(tags = "用户管理 ", value = "/permission/centre/v1/user")
@RequestMapping(value = "/permission/centre/v1/user")
public interface UserApi {

    /**
     * @Description: TODO
     * @Author: Administrator
     * @DATE: 2022-9-28  21:01
     * @param: 用户id
     * @return: 用户所对应的角色的权限列表
     */
    @GetMapping(value = "/getUserResource")
    List<ResourceVO> getUserResourceVO(Long id);

    /**
     * @Description: 用户管理界面增加页面保存数据调用此接口
     * @Author: Administrator
     * @DATE: 2022-9-28  21:12
     * @param:
     * @return:
     */
    @ApiOperation(tags = "增加用户", value = "")
    @PostMapping(value = "")
    @ResponseBody
    Boolean add(@RequestBody @Valid UserDTO userDTO);

    /**
     * @param: 删除用户，若有对应角色则中间表用户-角色也需一并删除
     * @return: 成功则true CommonResponse 应答码和消息统一参考基础框架
     * @see
     * @since
     */
    @ApiOperation(tags = "删除用户", value = "")
    @DeleteMapping(value = "")
    @ResponseBody
    Boolean remove(@ApiParam(value = "当前行id", required = true) @RequestParam("id") Long id,
                   @ApiParam(value = "当前行版本", required = true) @RequestParam("version") Long version);


    /**
     * @param: 用户DTO
     * @return: 成功则true CommonResponse 应答码和消息统一参考基础框架
     * @see
     * @since
     */
    @ApiOperation(tags = "修改用户", value = "")
    @PutMapping(value = "")
    @ResponseBody
    Boolean modify(@Valid @RequestBody UserDTO userDTO);

    /**
     * @param: 用户DTO
     * @return: 成功则true CommonResponse 应答码和消息统一参考基础框架
     * @see
     * @since
     */
    @ApiOperation(tags = "修改用户角色", value = "")
    @PutMapping(value = "/modifyWithNewRole")
    @ResponseBody
    Boolean modifyWithNewRole(@Valid @RequestBody UserDTO[] userDTOS);

    /**
     * @param: 用户查询条件
     * @return: 用户VO
     * @see
     * @since
     */

    @ApiOperation(tags = "查询用户", value = "")
    @GetMapping(value = "")
    @ResponseBody
    List<User> commonQuery(UserQuery userQuery);
    
    /**
     * @param: 用户ID
     * @return: 用户VO
     * @see
     * @since
     */
    @ApiOperation(tags = "查询用户通过ID", value = "")
    @GetMapping(value = "{id}")
    @ResponseBody
    UserVO queryUserById(@PathVariable("id") Long id);

    /**
     * @param:
     * @return:
     * @see
     * @since
     */
    @ApiOperation(tags = "查询所有角色", value = "")
    @GetMapping(value = "/queryAllRole")
    @ResponseBody
    List<Role> queryAllRole();

    /**
     * @param:
     * @return:
     * @see
     * @since
     */
    @ApiOperation(tags = "查询所有部门", value = "")
    @GetMapping(value = "/queryAllDepartment")
    @ResponseBody
    List<Department> queryAllDepartment();

    /**
     * @param:
     * @return:
     * @see
     * @since
     */
    @ApiOperation(tags = "查询所有职业", value = "")
    @GetMapping(value = "/queryAllPosition")
    @ResponseBody
    List<Position> queryAllPosition();


    /**
     * @param: 用户DTO数组
     * @return: 成功则true CommonResponse 应答码和消息统一参考基础框架
     * @see
     * @since
     */
    @ApiOperation(tags = "批量修改用户", value = "")
    @PutMapping(value = "/batchUpdate")
    @ResponseBody
    Boolean batchUpdate(@Valid @RequestBody UserDTO[] userDTOS);

    /**
     * @param: 用户DTO数组
     * @return: 成功则true CommonResponse 应答码和消息统一参考基础框架
     * @see
     * @since
     */
    @ApiOperation(tags = "批量删除用户", value = "")
    @DeleteMapping(value = "/batchDelete")
    @ResponseBody
    Boolean batchDelete(@Valid @RequestBody UserDTO[] userDTOS);

    /**
     * @Description: TODO
     * @Author: Administrator
     * @DATE: 2022-9-28  20:58
     * @param: 
     * @return: 
     */
    @ApiOperation(tags = "启用md5", value = "")
    @GetMapping(value = "/firstStartMd5")
    @ResponseBody
    Boolean firstStartMd5();

    /**
     * @Description: 重新更新密码，本次培训项目不需要实现这个
     * @Author: Administrator
     * @DATE: 2022-9-28  20:58
     * @param: 主要包含用户的id和新旧的密码
     * @return: 成功true 失败false
     */
    @ApiOperation(tags = "updatePassword", value = "")
    @PutMapping(value = "/upwd")
    Boolean updatePassword(@RequestBody @Valid UserDTO userDTO);

    /**
     * @Description: TODO
     * @Author: Administrator
     * @DATE: 2022-9-28  20:57
     * @param: 
     * @return: 
     */
    @ApiOperation(tags = "找回密码", value = "")
    @GetMapping(value = "/getUserByCode")
    User getUser(@RequestParam(value = "code") String code);
}
